package com.z8888q.zlottery.rewrite;

import com.z8888q.zlottery.Zlottery;

import android.os.Handler;
import android.os.Message;

public class RewriteHandler1 extends Handler{
	private Zlottery zsw;
	int directionX=1 , directionY=1;
	int radius=100;
	float current_angle=0;
	int dx=0,dy=0;
	float delta=0.3f; 
	float radian=(float) (Math.PI/180);
	int circlecenterX=125;	//125=320/2-35
	int circlecenterY=205;  //205=480/2-35
	int increment=40;
	public RewriteHandler1(Zlottery zsw){
		this.zsw=zsw;
		circlecenterX=zsw.screenWidth/2-10;
		circlecenterY=zsw.screenHeight/2-10;
		radius=100*zsw.screenWidth/320;
	}
	
	@Override public void handleMessage(Message msg){		

		// TODO Auto-generated method stub

		
		for(int i=0;i<=8;i++)
		if((zsw.image[i]!=null))
		{			
			
			zsw.angle += delta; 
			zsw.angle=zsw.angle%(360);
			current_angle=(zsw.angle+increment*i)%(360);

			dx = (int) (Math.cos(current_angle*radian)*radius)+circlecenterX; 
			dy = (int) (Math.sin(current_angle*radian)*radius)+circlecenterY; 

			zsw.image[i].layout(dx-zsw.image[i].getWidth()/2,dy-zsw.image[i].getHeight()/2,dx+zsw.image[i].getWidth()/2,dy+zsw.image[i].getHeight()/2);

//			sendEmptyMessage(0);
		}
//		super.handleMessage(msg);
	
	}
}
